import re

'''
只要目标字符串第一次匹配到reg中的任意一个,
则为成功
'''

reg1 = 'bike|car|road'
reg2 = 'road|bike|car'

str_1 = 'I rick my bike on the road.'
str_2 = 'On the road, I drive my car.'

res_1 = re.match(reg1, str_1)
res_2 = re.match(reg1, str_2)
print(res_1)
# None
print(res_2)
# None

res_3 = re.search(reg1, str_1)
res_4 = re.search(reg1, str_2)
print(res_3)
# <re.Match object; span=(10, 14), match='bike'>
print(res_4)
# <re.Match object; span=(11, 14), match='car'>

res_5 = re.search(reg2, str_1)
res_6 = re.search(reg2, str_2)
print(res_5)
# <re.Match object; span=(10, 14), match='bike'>
print(res_6)
# <re.Match object; span=(7, 11), match='road'>
